package com.mnc.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
@Entity
public class UserCollect implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 952641657053375235L;
	
	//收藏id
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int collectId;
	//收藏时间
	@Column
	private Date collectDate;
	//所有者
	@ManyToOne(cascade={CascadeType.REFRESH})
	//@JoinColumn(name="userId")
	private User owner;
	//收藏文章
	@ManyToMany(cascade={CascadeType.REFRESH},fetch=FetchType.EAGER)
	@JoinTable(name="Collect_Article",
	joinColumns= {@JoinColumn(name="collectId")},
	inverseJoinColumns= {@JoinColumn(name="articleId")})
	private Set<Article> collectArticles=new HashSet<Article>();
	//收藏空间
	@ManyToMany(cascade={CascadeType.REFRESH},fetch=FetchType.EAGER)
	@JoinTable(name="Collect_Page",
	joinColumns= {@JoinColumn(name="collectId")},
	inverseJoinColumns= {@JoinColumn(name="pageId")})
	private Set<UserPage> collectPages=new HashSet<UserPage>();
	public int getCollectId() {
		return collectId;
	}
	public void setCollectId(int collectId) {
		this.collectId = collectId;
	}
	public Date getCollectDate() {
		return collectDate;
	}
	public void setCollectDate(Date collectDate) {
		this.collectDate = collectDate;
	}
	public User getOwner() {
		return owner;
	}
	public void setOwner(User owner) {
		this.owner = owner;
	}
	public Set<Article> getCollectArticles() {
		return collectArticles;
	}
	public void setCollectArticles(Set<Article> collectArticles) {
		this.collectArticles = collectArticles;
	}
	public Set<UserPage> getCollectPages() {
		return collectPages;
	}
	public void setCollectPages(Set<UserPage> collectPages) {
		this.collectPages = collectPages;
	}
	
}
